package com.sky.mapper.common;

import com.sky.pojo.CourierTradeOrder;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface TradeOrderMapper {

    @Insert("INSERT INTO tb_courier_trade_order VALUES(NULL,#{totalAmount},#{courierId},#{orderNumber},#{waybillStatus},#{tradeCreateTime},#{tradeCompleteTime},#{tradeCancelTime},#{overTime},#{shopAddress},#{remark},#{customerAddress},#{customerExpectedDeliveryTime},#{customerName},#{shopName},#{toBeMealTime},#{telephone},#{income})")
    void insert(CourierTradeOrder tradeOrder);

    @Select("select * from tb_courier_trade_order where courier_id=#{courierId} and waybill_status = #{status}")
    List<CourierTradeOrder> selectList(@Param("status") Integer status,
                                       @Param("courierId") Long courierId);

    @Select("select * from tb_courier_trade_order where order_number=#{orderNum}")
    CourierTradeOrder selectByOrderNumber(String orderNum);

    @Select("select * from tb_courier_trade_order where trade_no = #{tradeNo}")
    CourierTradeOrder selectByTradeNo(String tradeNo);

    @Update("update tb_courier_trade_order set waybill_status = #{waybillStatus} where trade_no = #{tradeNo}")
    void updateStatusById(CourierTradeOrder tradeOrder);

    @Update("update tb_courier_trade_order set waybill_status = #{waybillStatus},trade_complete_time=#{tradeCompleteTime} where trade_no = #{tradeNo}")
    void updateStatusAndCompleteTimeById(CourierTradeOrder tradeOrder);


    @Update("update tb_courier_trade_order set courier_id = #{courierId} where trade_no = #{tradeNo}")
    void updateCourierById(@Param("tradeNo") String tradeNo,
                           @Param("courierId") Long courierId);
}
